from selenium import webdriver
from selenium.webdriver.common.by import By
import time

# 连接浏览器
driver=webdriver.Edge()
# 窗口最大化
driver.maximize_window()
# 找到浏览器
driver.get('http://10.59.9.12:7001/')
time.sleep(3)
# 定位登录
driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
time.sleep(3)
# 定位用户名
driver.find_element(By.NAME,'username').send_keys('13811033962')
# 定位密码
driver.find_element(By.NAME,'password').send_keys('123456')
time.sleep(10)
# 进行登录
driver.find_element(By.CLASS_NAME,'finish-btn').click()
time.sleep(3)
# 断言
dy1=driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').text
print(dy1)
time.sleep(3)
driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a').click()
time.sleep(2)
# 搜索
driver.find_element(By.CLASS_NAME,'search-input').send_keys('茅台')
driver.find_element(By.CLASS_NAME,'search-input-btn').click()
driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li[1]/div[1]/span/a/img').click()
driver.find_element(By.XPATH,'//*[@id="buy-cart"]').click()
time.sleep(3)


